<script language="javascript"> 
var arrEmotion = new Array();

var arrDefaultEmotion= new Array();
arrDefaultEmotion = ["http://public.blogbus.com/biaoqing/163/1.gif","http://public.blogbus.com/biaoqing/163/2.gif","http://public.blogbus.com/biaoqing/163/3.gif"];

function $(id) {
	return document.getElementById(id);
}

function insertEmotion() {
	var cmtForm = $("commentForm");
	if (!cmtForm) return;	
	if (arrEmotion.length != 0 ) {
		var emotionList = "";
		for (var i = 0; i < arrEmotion.length; i++) {
			emotionList += "<img src='";
			emotionList += arrEmotion[i];
			emotionList += "' onClick='addEm(\"[face:";
			emotionList += i;
			emotionList += "]\")' />";
		}
	} else {
		var emotionList = "";
		for (var i = 0; i < arrDefaultEmotion.length; i++) {
			emotionList += "<img src='";
			emotionList += arrDefaultEmotion[i];
			emotionList += "' onClick='addEm(\"[face:";
			emotionList += i;
			emotionList += "]\")' />";
		}
	}
	var divEmList = document.createElement("div");
	divEmList.setAttribute("id","emList");
	divEmList.innerHTML = emotionList;
	cmtForm.appendChild(divEmList);
//alert(emotionList);
}
function replaceEmotion() {
	var cmtLists = $("comments");
	if (!cmtLists) return;
	if (arrEmotion.length != 0 ) {
	cmtLists.innerHTML = cmtLists.innerHTML.replace(/\[face:(\d+)\]/g,function(a,b,c,d){return "<img src='" + arrEmotion[b] + "' />";});
	} else {
	cmtLists.innerHTML = cmtLists.innerHTML.replace(/\[face:(\d+)\]/g,function(a,b,c,d){return "<img src='" + arrDefaultEmotion[b-1] + "' />";});
	}
}


function addEm(code) {
	var f = document.forms;
	for (var i = 0; i <= f.length; i++) {
		if (f[i].checksum) {
			f[i].content.value += code;
			return;
		}
	}
}

if (document.all){
window.attachEvent('onload',replaceEmotion);
}
else{
window.addEventListener('load',insertEmotion,false);
}
/*window.onLoad = function() {
	insertEmotion();
	replaceEmotion();
}*/
</script>